/******************************************************************************
 * Copyright (C) 2020  QHHQ Co.,Ltd
 * All Rights Reserved.
 * 本软件为物连家美网络技术有限公司研制。未经本公司正式书面同意，其他任何个人、团体
 * 不得使用、复制、修改或发布本软件.
 *****************************************************************************/
package com.loop.demo.controller.test;

import com.loop.demo.annotation.ApiVersion;
import com.loop.demo.annotation.SwaggerApiVersion;
import com.loop.demo.constant.ApiVersionConstant;
import com.loop.demo.constant.SwaggerApiVersionConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: OrderController
 * @Desc: 注解放在类上，则所有接口都生效
 * @version: 1.0
 * @author: loop.fu
 * @date: 2021/8/9 8:48
 */
@RestController
@Api(tags = "订单模块")
@RequestMapping("/api/{version}/order")
public class OrderController {

    // 放在方法上，可以有多个版本
    @ApiOperation("新增订单")
    @PostMapping("/order/add")
    @SwaggerApiVersion({
            SwaggerApiVersionConstant.VERSION_1})
    @ApiVersion(ApiVersionConstant.VERSION_1)  // v1
    public String addOrder1(@PathVariable String version, Long userId1) {
        return "addOrder1";
    }

    @ApiOperation("新增订单")
    @PostMapping("/order/add")
    @SwaggerApiVersion({
            SwaggerApiVersionConstant.VERSION_2})
    @ApiVersion(ApiVersionConstant.VERSION_2)  // v2
    public String addOrder2(@PathVariable String version, Long userId2) {
        return "addOrder2";
    }

    @ApiOperation("新增订单")
    @PostMapping("/order/add")
    @SwaggerApiVersion({
            SwaggerApiVersionConstant.VERSION_3})
    @ApiVersion(ApiVersionConstant.VERSION_3)  // v1
    public String addOrder3(@PathVariable String version, Long userId3) {
        return "addOrder3";
    }

}